package web.servlet.owner;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.OwnerServiceImpl;
import domain.Owner;

public class FindOwnerByManyConditionServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");

		// 获取表单数据
		String ownerId = request.getParameter("ownerId");
		String ownerName = request.getParameter("ownerName");
		String ownerAddress = request.getParameter("ownerAddress");
		String ownerCity = request.getParameter("ownerCity");
		String ownerPhone = request.getParameter("ownerPhone");

		// 调用业务逻辑

		OwnerServiceImpl os = new OwnerServiceImpl();
		List<Owner> list = os.findOwnerByConditions(ownerId, ownerName, ownerAddress, ownerCity, ownerPhone);

		// 分发转向
		request.setAttribute("owners", list);// 把list放入request对象中
		request.getRequestDispatcher("/admin/owner/list.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}
}
